const path = require('path');
const str = 'C:/frontend/js/index.js'
let obj = path.parse(str);
console.log(obj);

/**
 * {
  root: '',
  dir: 'C:/frontend/js',
  base: 'index.js',
  ext: '.js',
  name: 'index'
}
 */

let line = path.format(obj)
console.log(line);

/**
 * C:/frontend/js/index.js
 */